
class Image:

    # 这里可以初始化类的属性
    def __init__(self, name):
        self.name = name
        self.link = ""
        self.format = "png"
        self.width = 600
        self.height = 800
        self.data = None

    # 定义类的函数
    def download(self, link):
        print("Donwloaded a image from link: " + link)
        self.link = link
        self.format = "jpg"
        self.width = 1000
        self.height = 600

    def save(self, file_name, file_format):
        print("Saving a image to file: " + file_name)
        print("The format is : " + file_format)

class ImagePNG(Image):

    # 这里可以初始化类的属性
    def __init__(self, name):
        super().__init__(name)
        self.transparency = 0.5
        self.format = "png"

    # 定义自己的方法
    def set_transparency(self, val):
        self.transparency = val

    # 覆盖父类的方法
    def save(self, file_name, file_format):
        print("Saveing a PNG image to file : " + file_name)

class ImageJPG(Image):

    # 这里可以初始化类的属性
    def __init__(self, name):
        super().__init__(name)
        self.compression = 2
        self.format = "jpg"

    # 定义自己的方法
    def set_compression(self, val):
        self.compression = val

    # 覆盖父类的方法
    def save(self, file_name, file_format):
        print("Saveing a JPG image to file : " + file_name)

